#define _CRT_SECURE_NO_WARNINGS 1

#include <string>
#include <vector>
using namespace std;

class Solution {
public:
    string longestCommonPrefix(vector<string>& strs) {
        string str = strs[0];
        for (int i = 0; i < strs.size(); ++i)
        {
            int max = 0;
            for (int j = 0; j < str.size() && str[j] == strs[i][j]; ++j)
            {
                ++max;
            }
            if (max < str.size())
            {
                str.erase(max);
            }
        }
        return str;
    }
};